#!/bin/bash

PC=`ps -ef|grep traffic.ini|grep -v grep|wc -l`
if [ $PC != 0 ]; then
    echo "is running... restart"
    rm -rf /tmp/traffic.log
    ps -ef|grep traffic.ini|grep -v grep|awk '{print $2}'|xargs kill -9
fi

while [ 1 -eq 1 ]; do
  PC=`ps -ef|grep traffic.ini|grep -v grep|wc -l`
  if [ $PC == 0 ]; then
    /usr/local/bin/uwsgi --ini /var/www/traffic/traffic.ini
    sleep 1
  else
    break
  fi
done
chmod 777 /tmp/traffic*
echo "is running..."
# touch /var/run/httpd/uwsgi.pid

